package com.kuang.functionalInterface;

import java.util.function.Predicate;

/**
 * Predicate 断定型接口
 *     一个输入，boolean输出
 *
 */
public class Test2 {
    public static void main(String[] args) {
        Predicate predicate = new Predicate<String>() {
            @Override
            public boolean test(String s) {
                return s.isEmpty();
            }
        };
        System.out.println(predicate.test("输出s"));
        System.out.println(predicate.test(""));

        // lambda简化
        Predicate<String> predicate1 = (str)->{return str.isEmpty();};
        Predicate<String> predicate11 = str->{return str.isEmpty();};
        Predicate<String> predicate2 = String::isEmpty;

        System.out.println(predicate1.test("简化"));
        System.out.println(predicate11.test(""));
        System.out.println(predicate2.test("简化"));
        System.out.println(predicate2.test(""));
    }
}
